/*
 *  Copyright (C) 2010 Glauco
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.balisunrise.annotation.util;

import org.balisunrise.annotation.VisualEntity;

/**
 * Utilitário para os Builders. Campos de VisualEntity.
 *
 * @author Glauco
 */
public class VisualEntityUtilities extends VisualizableUtilities{

    private static final String MESSAGE = "Erro ao ler Annotation \"VisualEntity\".";

    /**
     * Classe que a Entidade Visual representa.
     */
    public Class entityClass;

    /**
     * Alias para construção da Entidade Visual.
     */
    public String alias;

    /**
     * Título para a Entidade Visual.
     */
    public String title;

    /**
     * Le a annotation VisualEntity da classe.
     * 
     * @param entityClass classe.
     * @return VisualEntity
     * @throws AnnotationsUtilitiesException caso não encontre a annotation ou
     * o parametro seja nulo.
     */
    public static VisualEntity readVisualEntityAnnotation(Class entityClass)
            throws AnnotationsUtilitiesException{

         if (entityClass == null)
            throw new AnnotationsUtilitiesException( MESSAGE +
                    "\nParâmentro \"entityClass\" não pode ser nulo!");

         if(entityClass.isAnnotationPresent(VisualEntity.class))
             return (VisualEntity) entityClass.getAnnotation(VisualEntity.class);

         throw new AnnotationsUtilitiesException( MESSAGE +
                "\nAnnotation não encontrada!" );
    }
}
